<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>响应式原理1</title>
</head>

<body></body>



<script>
    let data = {};
    let name = 'hello';
    // 参数1:要操作的对象    参数2：要操作的属性   参数3：描述符对象
    Object.defineProperty(data, 'name', {
        get: function () {
            console.log('执行get');
            return name;
        },
        set: function (newValue) {
            console.log('执行set');
            name = newValue;
        },
    });
    data.name = 'vue';
    console.log(data.name);
</script>

</html>